// -----------------------------------------------------------------------
//  <copyright file="RoleResourceMapper.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2025 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025-03-01 22:03</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Authorization.Application.Queries;
using DaprPlus.Authorization.Domain.Entities;
using DaprPlus.AutoMapper;
using DaprPlus.Mapster;

using Mapster;


namespace DaprPlus.Identity.Infrastructure.Mapster;

public class RoleResourceMapper : MapsterTupleBase
{
    /// <summary>
    /// 执行对象映射构造
    /// </summary>
    public override void CreateMap()
    {
        TypeAdapterConfig<RoleResource, RoleResourceOutDto>.NewConfig()
            .Map(dest => dest.ResourceName,
                src => src.Resource.Name)
            .Map(dest => dest.ResourceCode,
                src => src.Resource.Code)
            .Map(dest => dest.MetadataJson,
                src => src.Resource.MetadataJson)
            .Map(dest => dest.AllowedOperationsJson,
                src => src.Resource.AllowedOperationsJson)
            .Map(dest => dest.Operations, src => src.GetOperations());
    }
}
